package cn.caixiong.basic.util;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(description = "json响应对象")
public class AjaxResult {
    @ApiModelProperty(value = "是否成功 true:成功 false:失败")
    private Boolean sucecess = true;
    @ApiModelProperty(value = "提示信息")
    private String message = "提交成功";
    @ApiModelProperty(value = "状态码 0000:成功 1000: 系统异常 1001:登录超时")
    private String code = PetConstant.SYSTEM_SUCCESS;
    @ApiModelProperty(value = "数据")
    private Object data;
//返回成功,不携带任何数据
    public static AjaxResult createSuccess(){
        return new AjaxResult();
    }
//返回成功,携带数据
public static AjaxResult createSuccess(Object data){
    return new AjaxResult(true,"ojbk",PetConstant.SYSTEM_SUCCESS,data);
}
//返回失败,自定义就用
public static AjaxResult createError(String code,String message){
    return new AjaxResult(false,message,code,null);
}
//返回失败对象,如果code就是1000系统异常,就用这个
    public static AjaxResult createError(String message){
        return createError(PetConstant.SYSTEM_ERROR,message);
    }
}
